package com.ruoyi.service;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class TestPg {
    public static void main(String[] args){
        //驱动类。
        String driver = "org.opengauss.Driver";
        //数据库连接描述符。
        String sourceURL = "jdbc:opengauss://192.168.1.85:5432/fire?";
        Connection connection;
        try {
            //加载驱动。
            Class.forName(driver);

            //创建连接。
            connection = DriverManager.getConnection(sourceURL, "fire", "Pa33w0rd");
            System.out.println("Connection succeed!");

            Statement stmt = connection.createStatement();
            ResultSet rs = stmt.executeQuery("select current_date");
            while(rs.next()){
                System.out.println("d:"+rs.getDate(1));
            }
            connection.close();
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
